Optimal. Leaf size=109 \[ \frac{2 a b \sin (x)}{\left (a^2+b^2\right )^2}-\frac{\left (a^2-b^2\right ) \cos (x)}{\left (a^2+b^2\right )^2}+\frac{a b^2}{\left (a^2+b^2\right )^2 (a \cos (x)+b \sin (x))}-\frac{b \left (b^2-2 a^2\right ) \tanh ^{-1}\left (\frac{b \cos (x)-a \sin (x)}{\sqrt{a^2+b^2}}\right )}{\left (a^2+b^2\right )^{5/2}} \]
[Out]
________________________________________________________________________________________
Rubi [A] time = 0.259293, antiderivative size = 151, normalized size of antiderivative = 1.39, number of steps used = 13, number of rules used = 8, integrand size = 18, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.444, Rules used = {3111, 3100, 2637, 3074, 206, 3109, 2638, 3155} \[ \frac{2 a b \sin (x)}{\left (a^2+b^2\right )^2}+\frac{b^2 \cos (x)}{\left (a^2+b^2\right )^2}-\frac{a^2 \cos (x)}{\left (a^2+b^2\right )^2}+\frac{a b^2}{\left (a^2+b^2\right )^2 (a \cos (x)+b \sin (x))}-\frac{b^3 \tanh ^{-1}\left (\frac{b \cos (x)-a \sin (x)}{\sqrt{a^2+b^2}}\right )}{\left (a^2+b^2\right )^{5/2}}+\frac{2 a^2 b \tanh ^{-1}\left (\frac{b \cos (x)-a \sin (x)}{\sqrt{a^2+b^2}}\right )}{\left (a^2+b^2\right )^{5/2}} \]
Antiderivative was successfully verified.
[In]
[Out]
Rule 3111
Rule 3100
Rule 2637
Rule 3074
Rule 206
Rule 3109
Rule 2638
Rule 3155
Rubi steps
\begin{align*} \int \frac{\cos ^2(x) \sin (x)}{(a \cos (x)+b \sin (x))^2} \, dx &=\frac{a \int \frac{\cos (x) \sin (x)}{a \cos (x)+b \sin (x)} \, dx}{a^2+b^2}+\frac{b \int \frac{\cos ^2(x)}{a \cos (x)+b \sin (x)} \, dx}{a^2+b^2}-\frac{(a b) \int \frac{\cos (x)}{(a \cos (x)+b \sin (x))^2} \, dx}{a^2+b^2}\\ &=\frac{b^2 \cos (x)}{\left (a^2+b^2\right )^2}+\frac{a b^2}{\left (a^2+b^2\right )^2 (a \cos (x)+b \sin (x))}+\frac{a^2 \int \sin (x) \, dx}{\left (a^2+b^2\right )^2}+2 \frac{(a b) \int \cos (x) \, dx}{\left (a^2+b^2\right )^2}-2 \frac{\left (a^2 b\right ) \int \frac{1}{a \cos (x)+b \sin (x)} \, dx}{\left (a^2+b^2\right )^2}+\frac{b^3 \int \frac{1}{a \cos (x)+b \sin (x)} \, dx}{\left (a^2+b^2\right )^2}\\ &=-\frac{a^2 \cos (x)}{\left (a^2+b^2\right )^2}+\frac{b^2 \cos (x)}{\left (a^2+b^2\right )^2}+\frac{2 a b \sin (x)}{\left (a^2+b^2\right )^2}+\frac{a b^2}{\left (a^2+b^2\right )^2 (a \cos (x)+b \sin (x))}+2 \frac{\left (a^2 b\right ) \operatorname{Subst}\left (\int \frac{1}{a^2+b^2-x^2} \, dx,x,b \cos (x)-a \sin (x)\right )}{\left (a^2+b^2\right )^2}-\frac{b^3 \operatorname{Subst}\left (\int \frac{1}{a^2+b^2-x^2} \, dx,x,b \cos (x)-a \sin (x)\right )}{\left (a^2+b^2\right )^2}\\ &=\frac{2 a^2 b \tanh ^{-1}\left (\frac{b \cos (x)-a \sin (x)}{\sqrt{a^2+b^2}}\right )}{\left (a^2+b^2\right )^{5/2}}-\frac{b^3 \tanh ^{-1}\left (\frac{b \cos (x)-a \sin (x)}{\sqrt{a^2+b^2}}\right )}{\left (a^2+b^2\right )^{5/2}}-\frac{a^2 \cos (x)}{\left (a^2+b^2\right )^2}+\frac{b^2 \cos (x)}{\left (a^2+b^2\right )^2}+\frac{2 a b \sin (x)}{\left (a^2+b^2\right )^2}+\frac{a b^2}{\left (a^2+b^2\right )^2 (a \cos (x)+b \sin (x))}\\ \end{align*}
Mathematica [A] time = 0.682217, size = 110, normalized size = 1.01 \[ \frac{2 b \left (b^2-2 a^2\right ) \tanh ^{-1}\left (\frac{a \tan \left (\frac{x}{2}\right )-b}{\sqrt{a^2+b^2}}\right )}{\left (a^2+b^2\right )^{5/2}}-\frac{-b \left (a^2+b^2\right ) \sin (2 x)+a \left (a^2+b^2\right ) \cos (2 x)+a^3-5 a b^2}{2 \left (a^2+b^2\right )^2 (a \cos (x)+b \sin (x))} \]
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A] time = 0.121, size = 144, normalized size = 1.3 \begin{align*} -4\,{\frac{-ab\tan \left ( x/2 \right ) +1/2\,{a}^{2}-1/2\,{b}^{2}}{ \left ({a}^{4}+2\,{a}^{2}{b}^{2}+{b}^{4} \right ) \left ( \left ( \tan \left ( x/2 \right ) \right ) ^{2}+1 \right ) }}+4\,{\frac{b}{ \left ({a}^{2}+{b}^{2} \right ) ^{2}} \left ({\frac{-1/2\,\tan \left ( x/2 \right ){b}^{2}-1/2\,ab}{ \left ( \tan \left ( x/2 \right ) \right ) ^{2}a-2\,b\tan \left ( x/2 \right ) -a}}-1/2\,{\frac{2\,{a}^{2}-{b}^{2}}{\sqrt{{a}^{2}+{b}^{2}}}{\it Artanh} \left ( 1/2\,{\frac{2\,a\tan \left ( x/2 \right ) -2\,b}{\sqrt{{a}^{2}+{b}^{2}}}} \right ) } \right ) } \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)] time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: ValueError} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] time = 0.542812, size = 586, normalized size = 5.38 \begin{align*} \frac{6 \, a^{3} b^{2} + 6 \, a b^{4} - 2 \,{\left (a^{5} + 2 \, a^{3} b^{2} + a b^{4}\right )} \cos \left (x\right )^{2} + 2 \,{\left (a^{4} b + 2 \, a^{2} b^{3} + b^{5}\right )} \cos \left (x\right ) \sin \left (x\right ) - \sqrt{a^{2} + b^{2}}{\left ({\left (2 \, a^{3} b - a b^{3}\right )} \cos \left (x\right ) +{\left (2 \, a^{2} b^{2} - b^{4}\right )} \sin \left (x\right )\right )} \log \left (-\frac{2 \, a b \cos \left (x\right ) \sin \left (x\right ) +{\left (a^{2} - b^{2}\right )} \cos \left (x\right )^{2} - 2 \, a^{2} - b^{2} + 2 \, \sqrt{a^{2} + b^{2}}{\left (b \cos \left (x\right ) - a \sin \left (x\right )\right )}}{2 \, a b \cos \left (x\right ) \sin \left (x\right ) +{\left (a^{2} - b^{2}\right )} \cos \left (x\right )^{2} + b^{2}}\right )}{2 \,{\left ({\left (a^{7} + 3 \, a^{5} b^{2} + 3 \, a^{3} b^{4} + a b^{6}\right )} \cos \left (x\right ) +{\left (a^{6} b + 3 \, a^{4} b^{3} + 3 \, a^{2} b^{5} + b^{7}\right )} \sin \left (x\right )\right )}} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F(-1)] time = 0., size = 0, normalized size = 0. \begin{align*} \text{Timed out} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A] time = 1.24049, size = 275, normalized size = 2.52 \begin{align*} \frac{{\left (2 \, a^{2} b - b^{3}\right )} \log \left (\frac{{\left | 2 \, a \tan \left (\frac{1}{2} \, x\right ) - 2 \, b - 2 \, \sqrt{a^{2} + b^{2}} \right |}}{{\left | 2 \, a \tan \left (\frac{1}{2} \, x\right ) - 2 \, b + 2 \, \sqrt{a^{2} + b^{2}} \right |}}\right )}{{\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )} \sqrt{a^{2} + b^{2}}} + \frac{2 \,{\left (2 \, a^{2} b \tan \left (\frac{1}{2} \, x\right )^{3} - b^{3} \tan \left (\frac{1}{2} \, x\right )^{3} - a^{3} \tan \left (\frac{1}{2} \, x\right )^{2} - 4 \, a b^{2} \tan \left (\frac{1}{2} \, x\right )^{2} - 3 \, b^{3} \tan \left (\frac{1}{2} \, x\right ) + a^{3} - 2 \, a b^{2}\right )}}{{\left (a \tan \left (\frac{1}{2} \, x\right )^{4} - 2 \, b \tan \left (\frac{1}{2} \, x\right )^{3} - 2 \, b \tan \left (\frac{1}{2} \, x\right ) - a\right )}{\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]